<html>
<body>
Reports construction of (temporary) new objects inside <code>equals()</code>, <code>hashCode()</code>, <code>compareTo()</code>, and
<code>Comparator.compare()</code> methods.
<p>
  Besides constructor invocations, new objects can also be created by autoboxing or iterator creation inside a
  <code>foreach</code> statement.
  This can cause performance problems, for example, when objects are added to a <code>Set</code> or <code>Map</code>,
  where these methods will be called often.
</p>
<p>
  The inspection will not report when the objects are created in a <code>throw</code> or <code>assert</code> statement.
</p>
<p><b>Example:</b></p>
<pre><code>
  class Person {
    private String name;
    private int age;

    public boolean equals(Object o) {
      return Arrays.equals(new Object[] {name, age}, new Object[] {((Foo)o).name, ((Foo)o).age});
    }

    public int hashCode() {
      return (name + age).hashCode();
    }
  }
</code></pre>
<p>
  In this example, two additional arrays are created inside <code>equals()</code>, usages of <code>age</code> field require boxing,
  and <code>name + age</code> implicitly creates a new string.
</p>
<!-- tooltip end -->
</body>
</html>